﻿using UnityEngine;
using System.Collections;

public class BulletCollideDetection : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter2D( Collider2D other )
	{
		BulletInfo bulletInfo = gameObject.GetComponent<BulletInfo>();
		PlaneInfo planeInfo = other.gameObject.GetComponent<PlaneInfo> ();
		if (planeInfo) {
			if(bulletInfo.isGood && !planeInfo.isGood){
				GameObject.Instantiate(Resources.Load("Prefabs/explo-mis1", typeof(GameObject)),transform.position,transform.rotation);
				Destroy(gameObject);
			}else if(!bulletInfo.isGood && planeInfo.isGood){
				GameObject.Instantiate(Resources.Load("Prefabs/explo-mis1", typeof(GameObject)),transform.position,transform.rotation);
				Destroy(gameObject);
			}	
		}
	}
}







